﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.OleDb;
using System.Data;
using DTO;

namespace DAO
{
    public class PhieuThuTienDAO : AbstractDAO
    {
        public List<PhieuThuTienDTO> GetAll()
        {
            OleDbConnection connection = Open();
            string sql = "SELECT * FROM PhieuThu";
            OleDbCommand command = new OleDbCommand(sql, connection);
            OleDbDataReader reader = command.ExecuteReader();
            List<PhieuThuTienDTO> dsPhieuThuTien = new List<PhieuThuTienDTO>();
            PhieuThuTienDTO s;
            while (reader.Read())
            {
                s = new PhieuThuTienDTO();
                s.MaPhieuThuTien = reader.GetInt32(0);
                s.MaKhachHang = reader.GetInt32(1);
                s.NgayThuTien = reader.GetDateTime(2);
                s.SoTienThu = reader.GetDouble(3);
                s.TinhTrang = reader.GetBoolean(4);
                dsPhieuThuTien.Add(s);
            }
            Close(connection);
            return dsPhieuThuTien;
        }
    }
}
